﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace EZhouReportConvertTool
{
    public class Config
    {

        public string TemplatePath { get; set; }
        public string OriginalCSVPath{ get; set; }
        public string ExprotFilePath { get; set; }
        public string MergeTemplateFilePath{ get; set; }
        public string MergeFileInputFilePath{ get; set; }

        public List<BinMap> BinMapList { get; set; } = new List<BinMap>();

        public List<BinMap> MergeBinMapList { get; set; } = new List<BinMap>();

        public void Save()
        {
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{nameof(Config)}.json");
            var str = JsonConvert.SerializeObject(this);
            File.WriteAllText(path, str);

        }

        public static Config Load()
        {
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{nameof(Config)}.json");
            if (File.Exists(path) == false) return new Config();
            var str = File.ReadAllText(path);
            var config = JsonConvert.DeserializeObject<Config>(str);
            return config;
        }

    }

    public class ConfigHelper
    {
        



    }


    public class BinMap
    {
        public string OriginalBinCode { get; set; }
        public string NewBinCode { get; set; }

        public uint BinLevel { get; set; } = 0;
    }


}
